#region show
<template>
  <q-tree
    selectable
    multiple
    :data="data"
    v-model:selected-keys="selectedValue"
  />
</template>

<script setup lang="ts">
import { ref, watch } from 'vue'
import { TreeOption } from 'qing-design'

function createData(level = 4, baseKey = ''): TreeOption[] | undefined {
  if (!level) return undefined
  return new Array(6 - level).fill(null).map((_, index) => {
    const key = '' + baseKey + level + index
    return {
      label: createLabel(level),
      key,
      children: createData(level - 1, key)
    }
  })
}

function createLabel(level: number): string {
  if (level === 4) return '道生一'
  if (level === 3) return '一生二'
  if (level === 2) return '二生三'
  if (level === 1) return '三生万物'
  return ''
}

const data = createData()
const selectedValue = ref([])

watch(selectedValue, val => {
  console.log(val)
})
</script>
#endregion show
